<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>
<link href="${ctx.resource}/css/select2.css" rel="stylesheet">
<link href="${ctx.resource}/css/select2-bootstrap.css" rel="stylesheet">
<title>收款流水 - 租房宝金融管理平台</title>

</head>
<body>

	<%@ include file="/WEB-INF/include/header.jsp"%>

	<div class="web-g-main">

		<%@ include file="/WEB-INF/include/aside.jsp"%>
		<div class="content">
			<header class="header clearfix">
				<h3 class="pull-left">收款流水</h3>
			</header>
			<form id="params" method="GET" action="${ctx}/flow/receipt/search">
				<input type="hidden" name="filter" value="true">
				<div class="container">
					<div class="row">

						<div class="col-xs-4">

							<div class="input-group pull-left">
								<span class="input-group-addon" id="basic-addon1">订单号</span> <input
									type="text" class="form-control" name="orderNo"
									value="${orderNo}" placeholder="输入订单号"
									aria-describedby="basic-addon1">
							</div>

						</div>

						<div class="col-xs-4">

							<div class="input-group pull-left">
								<span class="input-group-addon" id="basic-addon1">商户支付单号</span>
								<input type="text" class="form-control" name="merchantPaymentNo"
									value="${merchantPaymentNo}" placeholder="输入商户支付单号"
									aria-describedby="basic-addon1">
							</div>

						</div>
					</div>
					<br>
					<div class="row">
						<div class="col-xs-4">
							<div class="input-group">
								<span class="input-group-addon">商户</span> <select name="app_id"
									class="form-control">
									<c:if test="${role eq 'ROLE_SUPER_USER'}">
									<option value=""></option>
									</c:if>
									<c:forEach var="item" items="${appList}">
										<option value="${item.id }"
											<c:if test="${item.id eq app }">selected</c:if>>${item.name }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="col-xs-4">
							<div class="input-group pull-left">
								<span class="input-group-addon">确认时间</span>
								<input type="date" class="form-control input-date"
									name="startDate" value="${ startDate}" /> <span
									class="input-group-addon">至</span> <input type="date"
									class="form-control input-date" name="endDate"
									value="${endDate }" />
							</div>
						</div>
					</div>
					<br>
					<div class="row">
						<div class="col-xs-4">
							<div class="input-group pull-left">
								<span class="input-group-addon" id="basic-addon1">请选择支付方式</span>
								<select name="paymentMode"
									class="form-control">
									<c:if test="${paymentModes.size() > 1}">
									<option value=""></option>>
									</c:if>
									<c:forEach var="item" items="${paymentModes}">
										<option value="${item.id }" <c:if test="${item.id eq paymentMode}">selected</c:if>>${item.name}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="col-xs-2">
							<div class="btn-group pull-right">
								<button
									class="btn btn-default btn-shadow btn-shadow-default demo2do-btn">
									<i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;查询
								</button>
							</div>
						</div>
						<div class="col-xs-4">
							<div class="btn-group">
									<input name="excel" value="create" type="hidden">
									<a id="createExcel"
										class="btn btn-default btn-shadow btn-shadow-default">
										<i class="glyphicon glyphicon-book"></i>&nbsp;&nbsp;生成Excel文件
									</a>
							</div>
						</div>
					</div>
				</div>
			</form>
			<br>
			<c:if test="${not empty infoMessage}">
				<div
					class="alert alert-success alert-dismissable alert-fade top-margin-10 text-align-center">
					<button type="button" class="close" data-dismiss="alert">&times;</button>
					<i class="glyphicon glyphicon-info-sign"></i>&nbsp;&nbsp;
					<fmt:message key="${infoMessage}" />
				</div>
			</c:if>
			<div class="table-area">
				<table class="data-list">
					<thead>
						<tr>
							<th>交易号</th>
							<th>订单号</th>
							<th>订单状态</th>
							<th>订单总金额</th>
							<th>商户支付单号</th>
							<th>付款人</th>
							<th>打款方式</th>
							<th>支付时间</th>
							<th>确认时间</th>
							<th>支付金额</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="transactionRecord"
							items="${transactionRecordList}">
							<c:set var="order" value="${data.getOrderByOrderNoAndApp(transactionRecord.orderNo,transactionRecord.app) }"></c:set>
							<tr>
								<td>${transactionRecord.tradeNo}</td>
								<c:if test="${role eq 'ROLE_SUPER_USER'}">
								<td><a href="${ctx}/orders/all/${order.id}/detail"
									class="hover-no-text-decoration">${transactionRecord.orderNo}</a></td>
								</c:if>
								<c:if test="${role ne 'ROLE_SUPER_USER'}">
								<td>${transactionRecord.orderNo}</td>
								</c:if>
								<td><fmt:message key="${order.orderStatus.key}" /></td>
								<td>&yen;&nbsp;${order.totalRent}</td>
								<td>${transactionRecord.merchantPaymentNo}</td>
								<td>${data.getOrder(transactionRecord.orderNo).customer.name}</td>
								<td>${transactionRecord.paymentInstitution.name}</td>
								<td><fmt:formatDate
										value="${transactionRecord.customerPayTime}"
										pattern="yyyy/MM/dd HH:mm:SS" /></td>
								<td><fmt:formatDate
										value="${transactionRecord.lastModifiedTime}"
										pattern="yyyy/MM/dd HH:mm:SS" /></td>
								<td>&yen;&nbsp;${transactionRecord.payMoney}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				<c:choose>
					<c:when test="${not empty queryString}">
						<jsp:include page="/WEB-INF/include/page.jsp">
							<jsp:param name="url" value="flow/receipt/search" />
							<jsp:param name="queryString" value="${queryString}" />
						</jsp:include>
					</c:when>
					<c:otherwise>
						<jsp:include page="/WEB-INF/include/page.jsp">
							<jsp:param value="flow/receipt" name="url" />
						</jsp:include>
					</c:otherwise>
				</c:choose>
			</div>

			<%@ include file="/WEB-INF/include/footer.jsp"%>

		</div>

	</div>

	<%@ include file="/WEB-INF/include/script.jsp"%>
	<script src="${ctx.resource}/js/bootstrap-switch.min.js"></script>
	<script src="${ctx.resource}/js/bootstrap-modal-trigger.js"></script>
	<script src="${ctx.resource}/js/select2.min.js"></script>
	<script src="${ctx.resource}/js/select2_locale_zh-CN.js"></script>
	<script src="${ctx.resource}/js/bootstrap.validate.js"></script>
	<script src="${ctx.resource}/js/bootstrap.validate.en.js"></script>
	<script src="${ctx.resource}/js/earth-preupload.js"></script>
	<script src="${ctx.resource}/js/bootstrap-alert-fade-trigger.js"></script>

	<script src="${ctx.resource}/js/bootstrap-datepicker.js"></script>
	<script src="${ctx.resource}/js/bootstrap-datepicker.zh-CN.js"></script>

	<script type="text/javascript">
		$('.settlement-history .input-daterange').datepicker({
			format : "yyyy-mm-dd",
			startDate : "new Date()",
			todayBtn : "linked",
			language : "zh-CN",
			orientation : "top left",
			autoclose : true,
			todayHighlight : true
		});
	</script>

	<script type="text/javascript">
		$("#createExcel").click(function(){
			var data = $("#params").serialize();
			window.location.href="${ctx}/flow/receipt/result-create-excel?"+data;
			alert("生成中，请稍候！");
		});
	</script>
</body>
</html>
